<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>报告内容管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			$("#examType").bind('change',function(){
				var selected = $("#examType").val();
				$("#category").empty();
				if(selected == 1){
					 $.ajax({
			             type: "POST",
			             url: "${ctx}/sys/dict/listData",
			             data: {type:'exam_category'},
			             dataType: "json",
			             success: function(data){
			            	 var html = ''
	            	 		 html += "<select name='resultCategory'>";
	                         $.each(data, function(commentIndex, comment){
			            	 	html += "<option value='"+ comment.value + "'>" + comment.label + "</option>";
	                         });
	                         html += "</select><span class='help-inline'><font color='red'>*</font></span>";
	                         $("#category").append(html);
			            }
			        });
				}
				if(selected == 2){
					 $.ajax({
			             type: "POST",
			             url: "${ctx}/sys/dict/listData",
			             data: {type:'mbti_report_type'},
			             dataType: "json",
			             success: function(data){
			            	 var html = ''
	            	 		 html += "<select name='resultCategory'>";
	                         $.each(data, function(commentIndex, comment){
			            	 	html += "<option value='"+ comment.value + "'>" + comment.label + "</option>";
	                         });
	                         html += "</select><span class='help-inline'><font color='red'>*</font></span>";
	                         $("#category").append(html);
			            }
			        });
				}
			})
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/front/report/">报告内容列表</a></li>
		<li class="active"><a href="${ctx}/front/report/form?id=${report.id}">报告内容<shiro:hasPermission name="front:report:edit">${not empty report.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="front:report:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="report" action="${ctx}/front/report/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>		
		<div class="control-group">
			<label class="control-label">描述：</label>
			<div class="controls">
				<form:input path="detail" htmlEscape="false" maxlength="255" class="input-xlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">测试类型：</label>
			<div class="controls">
				<form:select path="examType" class="input-xlarge required">
					<form:option value="" label=""/>
					<form:options items="${fns:getDictList('exam_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">结果分类：</label>	
			<div id="category" class="controls">
				<c:if test="${not empty report.examType}">
					<form:select path="resultCategory" class="input-xlarge required">
						<form:option value="" label=""/>
						<c:if test="${report.examType == 1}">
							<form:options items="${fns:getDictList('exam_category')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</c:if>
						<c:if test="${report.examType == 2}">
							<form:options items="${fns:getDictList('exam_category')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</c:if>
					</form:select>
				</c:if>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">内容：</label>
			<div class="controls">
				<form:textarea id="content" htmlEscape="false" path="content" rows="4" maxlength="200" class="input-xxlarge"/>
				<sys:ckeditor replace="content" uploadPath="/cms/news" />
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="front:report:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>